use dataset_fort_worth_cross, clear

#delimit;

gr tw
	(sc pctyesed pctyesnoned [aw=totalvotes], msym(Oh) msize(tiny))
	(lfit pctyesed pctyesnoned [aw=totalvotes], col(black) lwid(thick))
		,
		by(year, rows(1) note("") xrescale yrescale legend(off)
		 title("(a) Relationship Between Election Day and Early Vote"))
		plotregion(style(none))
		subtitle(, fcol(none) lwid(none))
		ytitle("Election Day Votes")
		xtitle("Early/Absentee Votes")
		name(g1, replace)
		;
	
#delimit cr

gr close

cor pctyesed pctyesnoned [aw=totalvotes] if year == 2009
cor pctyesed pctyesnoned [aw=totalvotes] if year == 2014
cor pctyesed pctyesnoned [aw=totalvotes] if year == 2020

gen x = pctyesed - pctyesnoned

bys year: su x

#delimit;

gr tw
	(hist x)
	,
		by(year, rows(1) note("") 
		title("(b) Deviations Between Election Day and Early Vote"))
		plotregion(style(none))
		subtitle(, fcol(none) lwid(none))
		xtitle("(Election Day) - (Early/Absentee)")
		name(g2, replace)
		ylab(0 "" 5 "", angle(horiz))
		yscale(off)
		;
		
#delimit cr		

gr close

gr combine g1 g2, rows(2) xsize(2) ysize(2)

gr export "_output/figure A15.pdf", replace
